<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Keu_rpt extends MY_Controller {
	
	function __construct()
	{
		parent::__construct(); 
		
		$this->load->model('keu_rpt_model', 'GLReport');
		$this->load->model('combo_model', 'Combo');
		$this->secure_session();
	}
	
	function index(){
		$data['title'] = "GL Report";
		$data['data'] = null;
		$data['data']['date_from'] 	= date('01/m/Y');
		$data['data']['date_to'] 	= date('d/m/Y');
		$data['arr_report'] 		= json_encode($this->GLReport->SWReportType());
		$data['office_data']		= json_encode(array_merge(array(array('value'=>'','display'=>'')),$this->Combo->SWOffice()));		
		$data['cost_center_data']	= json_encode(array_merge(array(array('value'=>'','display'=>'')), $this->Combo->SWCostCenter()));
		
		
		viewByTemplate('keu_rpt/index', $data, 'grid');
	}
	
		
	function print_glreport(){
		$adt_date_from		= get('date_from');
		$as_kd_kantor		= get('kd_kantor');
		$kd_cost_center		= get('kd_cost_center');
		$as_report_code		= get('report_code');
		
		$adt_date_from		= ($adt_date_from=='' ? date('d/M/Y') : $adt_date_from);
		$as_kd_kantor		= ($as_kd_kantor=='' ? '%' : $as_kd_kantor);
		$kd_cost_center	= ($kd_cost_center=='' ? '%' : $kd_cost_center);
	
		
			
			// Load FPDF
			$this->load->helper('fpdf');
			
			// Set Data
			$arr_type = $this->GLReport->GetReportType($as_report_code);
			$data['tgl'] =$adt_date_from;
			if ($arr_type['tipe_report']=='L'){
				$data['data']	   = $this->GLReport->GetReportDataArusKas($as_report_code, $adt_date_from,  $as_kd_kantor, $kd_cost_center);
				$this->load->view('keu_rpt/print_report_labarugi', $data);
			}else if ($arr_type['tipe_report']=='N'){ 
				$data['data']	   = $this->GLReport->GetReportDataNeraca($as_report_code, $adt_date_from, $as_kd_kantor, $kd_cost_center);
				$this->load->view('keu_rpt/print_report_neraca', $data);
			/*}else if ($arr_type['tipe_report']=='R'){ 
				$data['data']	   = $this->GLReport->GetReportDataNeracaLajur($as_report_code, $adt_date_from,  $as_kd_kantor, $kd_cost_center);
				$this->load->view('keu_rpt/print_report_neracalajur', $data);*/
			}else{
				$data['data']	   = $this->GLReport->GetReportDataArusKas($as_report_code, $adt_date_from,  $as_kd_kantor, $kd_cost_center);
				$this->load->view('keu_rpt/print_report_aruskas', $data);
			}
			
		
	}
}
?>